<extend name="./app/Tpl/Public/template.html" />
<block name="content_body">
	<div class="pad-lr-10">
		<form name="form_search" id="form_search" action="{:U('showProductList')}" method="post">
		    <table width="100%" cellspacing="0" class="search-form">
		        <tbody>
		            <tr>
			            <td>
				            <div class="explain-col">							
								<select name="cate_code" style="width:250px;" class="chosen_search">
									<option value="">全部分类列表</option>
	                				<volist name="cateTree" id="val_1">
								    	<option value="{$val_1.code}"  <if condition="$val_1['code'] eq $search['cate_code']">selected</if>>{$val_1.code}-{$val_1.title}</option>
										<volist name="val_1['children']" id="val_2">
											<option value="{$val_2.code}"  <if condition="$val_2['code'] eq $search['cate_code']">selected</if>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$val_2.code}{$val_2.title}</option>								
										</volist>
	                				</volist>
								</select>
								<input type="text" name="code" value="{$search.code}" placeholder="商品代码">
								<input type="text" name="name" value="{$search.name}" placeholder="商品名称">
								<input type="button"  name="form_search_btn_search"  value="查询" onclick="document.forms['form_search'].submit()"/>
				        	</div>
			            </td>
		            </tr>
		        </tbody>
		    </table>
	    </form>
	    <form  name="form_list" id="form_list" action="{:U('index')}" method="post">
	    	<input type="hidden" name="auth_type" value="group">
		    <div class="table-list">		
			    <table width="100%" cellspacing="0">
			        <thead>
			            <tr>
			            	<th width="40" align="center">图片</th> 
			            	<th width="60" align="left">条形码</th>               
			                <th width="120" align="left">商品名称</th>
			                <th width="50" align="left">进货价</th>
			                <th width="50" align="left">零售价</th>
			                <th width="50" align="left">会员价</th>
			                <th width="80" align="left">规格/单位</th>
			      			<th width="40" align="left">分类</th>
			      			<th align="left">操作</th>
			            </tr>
			        </thead>
			    	<tbody>
						<volist name="list" id='val'>
				        <tr>
				        	<td align="center"><img src="{$val.id|m_prod_pic}?{$Think.now} "  id="pic_{$val.id}" width=45  height=30></td>
				            <td align="left">{$val.barcode}</td>
				            <td align="left"><span>{$val.name}</span></td>
				            <td align="left">{$val.price_buy}</td>
				            <td align="left">{$val.price_sale}</td>
				            <td align="left">{$val.price_vip}</td>
				            <td align="left">{$val.spec}/{$val.unit}</td>
							<td align="left">{$val.cate_code2}</td>		
				            <td align="left" class="btn">
				            	<a class="link_btn" href="{:U('showAdd',array('product_id'=>$val['id']))}" >新建订货单</a>
				            </td>
				        </tr>
				        </volist>
			    	</tbody>
			    </table>
	
			    <div class="btn">
					<div id="pages">{$page}</div>
			    </div>
	    	</div>
	    </form>
	</div>
	<div id="dialog_content" title="弹出框"></div>
<link rel="stylesheet" href="__ROOT__/statics/scripts/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="__ROOT__/statics/scripts/kindeditor/kindeditor-all-min.js"></script>
<script type="text/javascript">

$(function(){
	//打开编辑窗口
	$( "#dialog_content" ).dialog({
		autoOpen: false,
		width:500,
		height:400
	});
})

function doAdd(action_url){
	var cate_code = document.forms['form_search'].elements['cate_code'].value;
	var url = action_url+"?cate_code="+cate_code
	redirect(url);
}

function doUpd(action_url,type){
	var url = action_url
	if(type == 'cate'){
		var cate_code = document.forms['form_search'].elements['cate_code'].value;
		if(cate_code==''){
			alert('请选择分类');
			return;
		}
		url = url+"?cate_code="+cate_code;
	}
	redirect(url);
}

//删除操作
function doDel(action_url){
	if(confirm("确定删除选中项（如果选中项下有子菜单，会一同被删除）？")){
		$("#form_list").attr('action',action_url);
		$("#form_list").submit();
	}
	
}

//刷新菜单缓存文件
function removeCache(){
	$.get("{:U('removeCache')}", { }, function(jsondata){ 
		alert(jsondata);
	},'json'); 
}
</script>
</block>